﻿@model IEnumerable<dynamic>
@{
    ViewBag.Title = "User Manager";
    ViewBag.MnuLevel1 = "system";
    ViewBag.MnuLevel2 = "user";
    Layout = "~/Areas/Administrator/Views/Shared/_Layout.cshtml";
}
@section navigation
{
    <ul class="breadcrumbs">
        <li><a href="@Url.Action("Index",
                                 "Dashboard")"><i class="iconfa-home"></i></a><span class="separator">
                                                                              </span></li>
        <li>User Manager</li>
    </ul>
}
@section header
{
    <div class="pageheader">
        <div class="searchbar">
            <a href="@Url.Action("Add")" class="btn btn-primary btn-rounded"><i></i>&nbsp; Add User</a>
        </div>
        <div class="pageicon">
            <span class="iconfa-user"></span>
        </div>
        <div class="pagetitle">
            <h1>
                User Manager</h1>
        </div>
    </div>
}
@(Html.Telerik()
      .Grid(Model)
      .Name("grid")
      .Columns(c =>
                   {
                       c.Bound(typeof (int),
                               "Id")
                        .Title("#")
                        .Width(50);
                       c.Bound(typeof (string),
                               "Username")
                        .Title("User Name");
                       c.Bound(typeof (string),
                               "FirstName")
                        .Title("First Name");
                       c.Bound(typeof (string),
                               "LastName")
                        .Title("Last Name");
                       c.Bound(typeof (string),
                               "Email")
                        .Title("Email");
                       c.Template(v => v.Id)
                        .ClientTemplate(Html.ActionLink("<span class=\"t-icon t-edit\"></span>",
                                                        "Edit",
                                                        new
                                                            {
                                                                    id = "<#=Id#>"
                                                            },
                                                        new
                                                            {
                                                                    @class = "t-button t-button-icon t-grid-edit",
                                                            })
                                            .ToHtmlString() + "<a class=\"t-button t-button-icon t-grid-delete\" href=\"javascript:Delete(<#=Id#>);\"><span class=\"t-icon t-delete\"></span></a>")
                        .Width(80);
                   })
      .Sortable(c => c.Enabled(true))
      .Filterable()
      .DataKeys(c => c.Add("Id"))
      .Pageable(c =>
                    {
                        c.Enabled(true);
                        c.PageSize(25);
                    })
      .DataBinding(c => c.Ajax()
                         .Select("GetList",
                                 "User")))
@section script
{
    <script type="text/javascript">
        function Delete(id) {
            if (confirm("Do you want to delete?"))
                $.post('@Url.Action("Delete",
                                    "User")', { id: id }, function(data) {
                    showNotification(data);
                    $("#grid").data("tGrid").ajaxRequest();
                });
        }
    </script>
}